<template>
  <div class="rights_container">
    <!-- 面包屑导航栏 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>权限管理</el-breadcrumb-item>
      <el-breadcrumb-item>权限列表</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 权限列表卡片 -->
    <el-card class="box-card">
      <!-- 权限列表表格 -->
      <el-table :data="rightsList" border stripe="" style="width: 100%">
        <!-- 索引列 -->
        <el-table-column type="index" label="#" width="50"></el-table-column>
        <!-- 权限名称列 -->
        <el-table-column prop="authName" label="权限名称" width="220"></el-table-column>
        <!-- 路径列 -->
        <el-table-column prop="path" label="路径" width="220"></el-table-column>
        <!-- 权限等级列 -->
        <el-table-column prop="level" label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level == '0'">一级</el-tag>
            <el-tag type="success" v-if="scope.row.level === '1'">二级</el-tag>
            <el-tag type="info" v-if="scope.row.level == '2'">三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      rightsList: []
    }
  },
  created() {
    this.getRightsList()
  },
  methods: {
    // 请求权限列表数据
    async getRightsList() {
      const { data: res } = await this.$http.get('rights/list')
      // console.log(res)
      this.rightsList = res.data
    }
  }
}
</script>

<style lang="less" scoped></style>
